package com.sagframe.sagacity.sqltoy.plus.multi.update;

import com.sagframe.sagacity.sqltoy.plus.conditions.eumn.SqlKeyword;
import com.sagframe.sagacity.sqltoy.plus.multi.AbstractStringMultiWrapper;
import com.sagframe.sagacity.sqltoy.plus.multi.MultiContext;
import com.sagframe.sagacity.sqltoy.plus.multi.StringMultiStepWrapper;

public class MultiUpdateWrapper extends AbstractStringMultiWrapper<MultiUpdateWrapper> implements StringUpdate<MultiUpdateWrapper>{

    public MultiUpdateWrapper() {
        super((Class<?>)null);
        context.addOperateSqlSegment(SqlKeyword.UPDATE);
    }

    public MultiUpdateWrapper(MultiContext context) {
        super(context);
    }

    @Override
    protected MultiUpdateWrapper instance() {
        return new MultiUpdateWrapper(context);
    }

    @Override
    public <T> MultiUpdateWrapper set(boolean condition, String column, Object val) {
        if (condition) {
            context.addUpdateSqlAssembler(column, val);
        }
        return typedThis;
    }

    @Override
    public StringMultiStepWrapper.LambdaMatchJoin<MultiUpdateWrapper> from(Class<?> clazz, String alisaName) {
        return new StringMultiStepWrapper.MultiStepWrapperBuilder<>(typedThis, context).from(clazz, alisaName);
    }
}
